package com.offline.module.base.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.offdissys.common.db.page.PageParam;
import com.offline.module.base.entity.GoodsInfo;
import com.offline.module.base.service.goods.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * @author ZhangHaiWen
 * @title: GoodsController
 * @projectName mybatisplustest
 * @description: 商品信息
 * @date 2021/12/1315:50
 */
@RestController
@RequestMapping(value = "/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    /**
     * 创建商品
     * @return
     */
    @PostMapping(value = "/create")
    public GoodsInfo create(
            @RequestBody GoodsInfo goodsInfo
    ){
        return goodsService.create(goodsInfo);
    }

    /**
     * 商品列表
     * @return
     */
    @GetMapping(value = "/list")
    public List<GoodsInfo> list(){
        return goodsService.goodsInfos();
    }

    /**
     * 商品列表
     * @return
     */
    @PostMapping(value = "/list")
    public IPage<GoodsInfo> list(
            @RequestBody PageParam<GoodsInfo> pageParam
            ){
        return goodsService.list(pageParam);
    }

}
